package edu.online.dal;

import edu.online.entity.TeacherEntity;
import org.apache.ibatis.jdbc.SQL;

public class TeacherEntitySqlProvider {

    public String insertSelective(TeacherEntity record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("teacher");
        
        if (record.getUserid() != null) {
            sql.VALUES("UserId", "#{userid,jdbcType=CHAR}");
        }
        
        if (record.getUsername() != null) {
            sql.VALUES("UserName", "#{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPasswd() != null) {
            sql.VALUES("Passwd", "#{passwd,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            sql.VALUES("Email", "#{email,jdbcType=VARCHAR}");
        }
        
        if (record.getMobile() != null) {
            sql.VALUES("Mobile", "#{mobile,jdbcType=CHAR}");
        }
        
        if (record.getRole() != null) {
            sql.VALUES("Role", "#{role,jdbcType=VARCHAR}");
        }
        
        if (record.getTeachername() != null) {
            sql.VALUES("TeacherName", "#{teachername,jdbcType=VARCHAR}");
        }
        
        if (record.getTsex() != null) {
            sql.VALUES("TSex", "#{tsex,jdbcType=CHAR}");
        }
        
        if (record.getWechart() != null) {
            sql.VALUES("WeChart", "#{wechart,jdbcType=VARCHAR}");
        }
        
        if (record.getQq() != null) {
            sql.VALUES("QQ", "#{qq,jdbcType=VARCHAR}");
        }
        
        if (record.getCountry() != null) {
            sql.VALUES("Country", "#{country,jdbcType=VARCHAR}");
        }
        
        if (record.getSkype() != null) {
            sql.VALUES("Skype", "#{skype,jdbcType=VARCHAR}");
        }
        
        if (record.getSpecialty() != null) {
            sql.VALUES("Specialty", "#{specialty,jdbcType=VARCHAR}");
        }
        
        if (record.getBankinfo() != null) {
            sql.VALUES("BankInfo", "#{bankinfo,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(TeacherEntity record) {
        SQL sql = new SQL();
        sql.UPDATE("teacher");
        
        if (record.getUsername() != null) {
            sql.SET("UserName = #{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPasswd() != null) {
            sql.SET("Passwd = #{passwd,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            sql.SET("Email = #{email,jdbcType=VARCHAR}");
        }
        
        if (record.getMobile() != null) {
            sql.SET("Mobile = #{mobile,jdbcType=CHAR}");
        }
        
        if (record.getRole() != null) {
            sql.SET("Role = #{role,jdbcType=VARCHAR}");
        }
        
        if (record.getTeachername() != null) {
            sql.SET("TeacherName = #{teachername,jdbcType=VARCHAR}");
        }
        
        if (record.getTsex() != null) {
            sql.SET("TSex = #{tsex,jdbcType=CHAR}");
        }
        
        if (record.getWechart() != null) {
            sql.SET("WeChart = #{wechart,jdbcType=VARCHAR}");
        }
        
        if (record.getQq() != null) {
            sql.SET("QQ = #{qq,jdbcType=VARCHAR}");
        }
        
        if (record.getCountry() != null) {
            sql.SET("Country = #{country,jdbcType=VARCHAR}");
        }
        
        if (record.getSkype() != null) {
            sql.SET("Skype = #{skype,jdbcType=VARCHAR}");
        }
        
        if (record.getSpecialty() != null) {
            sql.SET("Specialty = #{specialty,jdbcType=VARCHAR}");
        }
        
        if (record.getBankinfo() != null) {
            sql.SET("BankInfo = #{bankinfo,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("UserId = #{userid,jdbcType=CHAR}");
        
        return sql.toString();
    }
}